package com.onstar.cn.api.v3;

import com.onstar.cn.api.framework.BaseApiService;
import com.onstar.cn.api.framework.ClazzInjectUtils;
import com.onstar.cn.api.framework.annotation.Path;
import com.onstar.cn.api.framework.annotation.RequestMapping;
import com.onstar.cn.framework.network.entity.RequestEntity;

/**
 * Created by 7828wc on 16/7/18.
 */
@Path("/msp/api/v3/vehicle")
public class JoinMeVehicle extends BaseApiService {
    public JoinMeVehicle(String serverUrl) {
        super(serverUrl);
    }

//    /api/v3/vehicle/info3/infotainment_capable/getVehicleUnit

    @RequestMapping("/info3/infotainment_capable/getVehicleUnit")
    public RequestEntity getVehicleUnit(RequestEntity entity, String vinOrGovId) {
        if (entity == null) {
            entity = new RequestEntity();
        }
        String url = ClazzInjectUtils.injectUrl(getClass(), "getVehicleUnit", entity, vinOrGovId);
//        http://113.52.176.197:51611
        url = url.replace("getVehicleUnit",vinOrGovId != null && vinOrGovId.length()==17?"getVinVehicleUnit":"getGidVehicleUnit");
        url = serverUrl + url + ((vinOrGovId != null && vinOrGovId.length() == 17 )? "?vin=" : "?gid=") + vinOrGovId;
        entity.setUrl(url);
        return entity;
    }

}
